package com.pgytesting.secondhandcar.service.impl;

import com.pgytesting.secondhandcar.model.BankCardInformation;
import com.pgytesting.secondhandcar.dao.BankCardInformationDao;
import com.pgytesting.secondhandcar.service.BankCardInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 银行卡信息(BankCardInformation)表服务实现类
 *
 * @author makejava
 * @since 2019-08-21 11:45:20
 */
@Service("bankCardInformationService")
public class BankCardInformationServiceImpl implements BankCardInformationService {
    @Resource
    private BankCardInformationDao bankCardInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param bankCardNumber 主键
     * @return 实例对象
     */
    @Override
    public BankCardInformation queryById(String bankCardNumber) {
        return this.bankCardInformationDao.queryById(bankCardNumber);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<BankCardInformation> queryAllByLimit(int offset, int limit) {
        return this.bankCardInformationDao.queryAllByLimit(offset, limit);
    }
    
    /**
     * 条件查询多条数据
     *
     * @param bankCardInformation 实例对象
     * @return 对象列表
     */
    @Override
    public List<BankCardInformation> queryAll(BankCardInformation bankCardInformation) {
        return this.bankCardInformationDao.queryAll(bankCardInformation);
    }

    /**
     * 新增数据
     *
     * @param bankCardInformation 实例对象
     * @return 实例对象
     */
    @Override
    public BankCardInformation insert(BankCardInformation bankCardInformation) {
        this.bankCardInformationDao.insert(bankCardInformation);
        return bankCardInformation;
    }

    /**
     * 修改数据
     *
     * @param bankCardInformation 实例对象
     * @return 实例对象
     */
    @Override
    public BankCardInformation update(BankCardInformation bankCardInformation) {
        this.bankCardInformationDao.update(bankCardInformation);
        return this.queryById(bankCardInformation.getBankCardNumber());
    }

    /**
     * 通过主键删除数据
     *
     * @param bankCardNumber 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String bankCardNumber) {
        return this.bankCardInformationDao.deleteById(bankCardNumber) > 0;
    }
}